home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
tex
/
rail.zip
/
GRAM.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-01-15
|
21KB
|
792 lines
extern char *malloc(), *realloc();
# line 4 "gram.y"
#include <stdio.h>
#include "rail.h"
char optchar;
# define IDENTIFIER 257
# define NUMBER 258
# define ANNOT 259
# define RAILI 260
# define RAILP 261
# define RAILT 262
# define RAILCR 263
# define CS 264
# define STRING 265
#define yyclearin yychar = -1
#define yyerrok yyerrflag = 0
extern int yychar;
extern int yyerrflag;
#ifndef YYMAXDEPTH
#define YYMAXDEPTH 150
#endif
YYSTYPE yylval, yyval;
# define YYERRCODE 256
# line 223 "gram.y"
int yyexca[] ={
-1, 1,
0, -1,
-2, 0,
-1, 25,
125, 43,
59, 43,
124, 43,
-2, 0,
-1, 43,
124, 43,
-2, 17,
};
# define YYNPROD 46
# define YYLAST 246
int yyact[]={
39, 44, 50, 51, 23, 39, 22, 6, 46, 16,
39, 3, 4, 5, 14, 39, 43, 64, 19, 39,
39, 17, 47, 25, 13, 11, 9, 53, 33, 37,
30, 27, 38, 60, 31, 36, 45, 2, 57, 7,
20, 18, 15, 12, 10, 8, 1, 34, 35, 26,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 48, 0, 0, 0, 0, 0, 0, 0, 0,
52, 0, 0, 0, 54, 56, 59, 55, 0, 0,
62, 62, 42, 61, 61, 63, 21, 66, 65, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
47, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 46, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 49, 24, 0,
0, 28, 29, 41, 32, 40, 0, 49, 41, 32,
40, 0, 49, 41, 58, 40, 49, 29, 41, 32,
40, 0, 41, 41, 40, 40 };
int yypact[]={
-249, -249, -1000, -97, -98, -99, -1000, -1000, -1000, -244,
-1000, -1000, -1000, -248, -104, -1000, -107, -1000, -39, -1000,
-100, -1000, -1000, -1000, -1000, -35, -43, -1000, -1000, -57,
-1000, -102, -21, -1000, -40, -1000, -1000, -1000, -36, -30,
-251, -1000, -1000, -20, -1000, -1000, -1000, -25, -1000, -251,
-21, -21, -1000, -1000, -24, -1000, -1000, -30, -21, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000 };
int yypgo[]={
0, 31, 49, 30, 34, 28, 48, 47, 35, 33,
32, 29, 36, 46, 37, 45, 44, 43, 42, 41,
40, 38 };
int yyr1[]={
0, 13, 13, 14, 14, 14, 14, 18, 16, 19,
19, 19, 19, 17, 20, 15, 2, 2, 2, 2,
21, 1, 1, 3, 4, 4, 4, 4, 5, 5,
5, 6, 6, 7, 7, 8, 8, 9, 9, 10,
10, 10, 10, 11, 12, 12 };
int yyr2[]={
0, 4, 2, 4, 4, 4, 2, 1, 9, 0,
5, 5, 5, 7, 1, 15, 7, 5, 2, 3,
1, 9, 3, 3, 9, 7, 5, 2, 7, 7,
2, 2, 2, 5, 2, 5, 2, 2, 2, 7,
5, 5, 3, 1, 3, 1 };
int yychk[]={
-1000, -13, -14, 260, 261, 262, 256, -14, -15, 123,
-16, 123, -17, 123, 258, -18, 257, 125, -19, 125,
-20, 125, 45, 43, 257, 123, -2, -1, 256, 257,
-3, -4, 259, -5, -7, -6, -8, -11, -10, 40,
265, 263, 125, 59, 58, -12, 259, 124, -5, 257,
42, 43, -8, 63, -4, -12, -1, -21, 259, -5,
-9, -10, -11, -9, 41, -3, -5 };
int yydef[]={
0, -2, 2, 0, 0, 0, 6, 1, 3, 0,
4, 7, 5, 0, 0, 9, 0, 14, 0, 13,
0, 8, 10, 11, 12, -2, 0, 18, 19, 45,
22, 23, 43, 27, 31, 30, 34, 32, 36, 43,
45, 42, 15, -2, 20, 41, 44, 43, 26, 45,
43, 43, 33, 35, 0, 40, 16, 43, 43, 25,
28, 37, 38, 29, 39, 21, 24 };
typedef struct { char *t_name; int t_val; } yytoktype;
#ifndef YYDEBUG
# define YYDEBUG 0 /* don't allow debugging */
#endif
#if YYDEBUG
yytoktype yytoks[] =
{
"IDENTIFIER", 257,
"NUMBER", 258,
"ANNOT", 259,
"RAILI", 260,
"RAILP", 261,
"RAILT", 262,
"RAILCR", 263,
"CS", 264,
"STRING", 265,
"-unknown-", -1 /* ends search */
};
char * yyreds[] =
{
"-no such reduction-",
"rails : rails rail",
"rails : rail",
"rail : RAILI raili",
"rail : RAILP railp",
"rail : RAILT railt",
"rail : error",
"railp : '{'",
"railp : '{' options '}'",
"options : /* empty */",
"options : options '-'",
"options : options '+'",
"options : options IDENTIFIER",
"railt : '{' IDENTIFIER '}'",
"raili : '{' NUMBER '}'",
"raili : '{' NUMBER '}' '{' rules '}'",
"rules : rules ';' rule",
"rules : rules ';'",
"rules : rule",
"rules : error",
"rule : IDENTIFIER ':'",
"rule : IDENTIFIER ':' body",
"rule : body",
"body : body0",
"body0 : body0 '|' ANNOT body1",
"body0 : body0 '|' body1",
"body0 : ANNOT body1",
"body0 : body1",
"body1 : body2 '*' body4e",
"body1 : body2 '+' body4e",
"body1 : body2e",
"body2e : body2",
"body2e : empty",
"body2 : body2 body3",
"body2 : body3",
"body3 : body4 '?'",
"body3 : body4",
"body4e : body4",
"body4e : empty",
"body4 : '(' body0 ')'",
"body4 : STRING annot",
"body4 : IDENTIFIER annot",
"body4 : RAILCR",
"empty : /* empty */",
"annot : ANNOT",
"annot : /* empty */",
};
#endif /* YYDEBUG */
#line 1 "/usr/lib/yaccpar"
/* @(#)yaccpar 1.10 89/04/04 SMI; from S5R3 1.10 */
/*
** Skeleton parser driver for yacc output
*/
/*
** yacc user known macros and defines
*/
#define YYERROR goto yyerrlab
#define YYACCEPT { free(yys); free(yyv); return(0); }
#define YYABORT { free(yys); free(yyv); return(1); }
#define YYBACKUP( newtoken, newvalue )\
{\
if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\
{\
yyerror( "syntax error - cannot backup" );\
goto yyerrlab;\
}\
yychar = newtoken;\
yystate = *yyps;\
yylval = newvalue;\
goto yynewstate;\
}
#define YYRECOVERING() (!!yyerrflag)
#ifndef YYDEBUG
# define YYDEBUG 1 /* make debugging available */
#endif
/*
** user known globals
*/
int yydebug; /* set to 1 to get debugging */
/*
** driver internal defines
*/
#define YYFLAG (-1000)
/*
** static variables used by the parser
*/
static YYSTYPE *yyv; /* value stack */
static int *yys; /* state stack */
static YYSTYPE *yypv; /* top of value stack */
static int *yyps; /* top of state stack */
static int yystate; /* current state */
static int yytmp; /* extra var (lasts between blocks) */
int yynerrs; /* number of errors */
int yyerrflag; /* error recovery flag */
int yychar; /* current input token number */
/* register YYSTYPE *yypvt = 0; /* top of value stack for $vars */
/*
** yyparse - return 0 if worked, 1 if syntax error not recovered from
*/
int
yyparse()
{
register YYSTYPE *yypvt = 0; /**/
unsigned yymaxdepth = YYMAXDEPTH;
/*
** Initialize externals - yyparse may be called more than once
*/
yyv = (YYSTYPE*)malloc(yymaxdepth*sizeof(YYSTYPE));
yys = (int*)malloc(yymaxdepth*sizeof(int));
if (!yyv || !yys)
{
yyerror( "out